<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
				<button onclick="testGet('http://poetry.apiopen.top/getTime')">获取当前日期和时间</button><br>
				<button onclick="testGet('http://poetry.apiopen.top/sentences')">随机一句名言</button><br>
				<button onclick="testGet('http://poetry.apiopen.top/poetryFull?count=1&page=1')">获取诗词列表-包含作者信息</button><br>
				<button onclick="testGet('http://poetry.apiopen.top/poetryAuthor?count=2&page=1&name=李白')">获取诗词作者列表</button><br>
				<button onclick="testGet('http://poetry.apiopen.top/poetry?count=2&page=1')">获取诗词列表</button><br>
				
				<button onclick="testPost('https://api.apiopen.top/getWangYiNews','1','1','1')">获取网易新闻</button><br>
				<button onclick="testPost('https://api.apiopen.top/getImages','1','1','1')">美图推荐</button><br>
				<button onclick="testPost('https://api.apiopen.top/likePoetry','李白','1','2')">模糊搜索古诗词-李白</button><br>
				<button onclick="testPost('https://api.apiopen.top/searchPoetry','古风二首 二','1','2')">获取-古风二首 二</button><br>
				<button onclick="testPost('https://api.apiopen.top/searchAuthors','李白','1','2')">搜索古诗词作者-李白</button>
	</body>
	<script type="text/javascript">
		function testGet(url){
			//创建一个XMLHttpRequest异步对象
			var ajax1 = new XMLHttpRequest();
			//设置请求方式和请求地址
			ajax1.open('GET',url);
			//用send发送请求
			ajax1.send();
			//监听状态变化
			ajax1.onreadystatechange = function(){
				if (ajax1.status ==200 && ajax1.readyState ==4) {
				var obj1 = JSON.parse(ajax1.responseText);
				//接收返回的数据
				console.log(obj1.result);
				}
			}
		}
		
		function testPost(url, par1, par2, choose) {
					var req = new XMLHttpRequest();
					req.open("post", url);
					if (choose == "1") {
						req.send("page=" + par1 + "&count=" + par2);
					} else if (choose == "2") {
						req.send("name=" + par1);
					}
					req.onreadystatechange = function() {
						if (req.readyState == 4 && req.status == 200) {
							console.log(req.responseText);
						}
					}
				}

		
	</script>
</html>
